home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Why doesn't this compile?
- Date: Mon, 18 Mar 96 22:04:33 GMT
- Organization: none
- Message-ID: <827186673snz@genesis.demon.co.uk>
- References: <4igck9$idj@masala.cc.uh.edu>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4igck9$idj@masala.cc.uh.edu> BSamuel@uh.edu "Binoy K. Samuel" writes:
-
- >Hi:
- >
- >I am taking a C class this semester.
- >
- >And I have just written a program that runs (more or less) quite well.
- >
- >However, when I try to compile it, I get the following error:
- >
- > "Call to function 'evalchar' with no prototype"
- >
- >Why does this happen? 'Evalchar' is a function that I wrote. What
- >prototype should I be looking for.
- >
- >Here's the function header line:
- >
- > char evalchar(cnum)
- > int cnum;
-
- This isn't a prototype. A prototype is a form of function declaration
- introduced with ANSI C that states type information in the parameter list,
- i.e. between the ()'s. The compiler can perform suitable argument type
- checking and conversion when a prototype is in scope. While prototypes aren't
- mandatory (the compiler should have just warned, not refused to generate
- an executable) the compiler is giving you good advice that you should use
- them. Prototyped forms look like:
-
- char evalchar(int cnum);
-
- for a declaration and
-
- char evalchar(int cnum)
- {
- /* ... */
- }
-
- for a function definition (i.e. where you rovide the function body).
-
- >I'm using Borland C++'s C compiler.
-
- If you wanted to compile a C program rather than C++ make sure you used the
- right compiler options.
-
- >Please e-mail me if you can. This is the first time I'm writing to this
- >newsgroup: I don't usually look here that often.
-
- However you've now posted a question so you have a very good reason to look
- more often (at least at this particular thread). comp.lang.c isn't a
- write-only newsgroup. If you post a question be prepared to read the answers
- here so that others can also see them and comment on them.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-